using System;
using System.Collections.Generic;
using System.Text;
using Wrath.Xml;
using System.ComponentModel;
using Wrath.RuleForge.Interfaces;

namespace Wrath.RuleForge.Property
{
    public sealed class ElementPropertyWrapper: IPropertyWrapper<Element>
    {
        private bool hasChanged;
        private Element dataElement;

        public ElementPropertyWrapper(Element element)
        {
            hasChanged = false;
            dataElement = element;
        }

        #region Properties

        [Category("Element")]
        [DisplayName("Name")]
        [Description("The tag name of this element.")]
        public string ElementName { get { return dataElement.Name; } }

        [Category("Element")]
        [DisplayName("Value")]
        [Description("The inner value of this element, if any.")]
        public string ElementValue { get { return dataElement.Value; } set { dataElement.Value = value; } }

        [Category("Element")]
        [Description("A collection of this element's attributes.")]
        public List<Wrath.Xml.Attribute> Attributes { get { return dataElement.Attributes; } }

        [Category("Element")]
        [Description("All child elements within this element.")]
        public List<Element> Children { get { return dataElement.ChildElements; } }

        #endregion

        #region IPropertyWrapper Members

        [Browsable(false)]
        public bool HasChanged
        {
            get
            {
                return hasChanged;
            }
            set
            {
                hasChanged = value;
            }
        }

        [Browsable(false)]
        public Element Data
        {
            get { return dataElement; }
        }

        #endregion
    }
}
